﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.Unity;

namespace ERPStore.Web.NewsLetters.IOC
{
	public class SignalRUnityDependencyResolver : Microsoft.AspNet.SignalR.DefaultDependencyResolver
	{
		private IUnityContainer _container;

		public SignalRUnityDependencyResolver(IUnityContainer container)
		{
			_container = container;
		}

		public override object GetService(Type serviceType)
		{
			if (_container.IsRegistered(serviceType)) return _container.Resolve(serviceType);
			else return base.GetService(serviceType);
		}

		public override IEnumerable<object> GetServices(Type serviceType)
		{
			if (_container.IsRegistered(serviceType)) return _container.ResolveAll(serviceType);
			else return base.GetServices(serviceType);
		}

	}
}
